//*************************************************************************************************************
//******Google APi setting 
//var clientId = '645088001997-nnvaa9ujn71r15ka780e1n1thao6a36e.apps.googleusercontent.com'; //jb-shhb->'828062657182-a2i7dlpvhlv2uqe4f101i1430qh1thmr.apps.googleusercontent.com';
var apiKey = 'AIzaSyAc57VU98o74PG99tuhBc1M7x5JNKK8eug'; //jb-shhb->'AIzaSyCZtTH-e9ZXKkNX07j7RzTtDttNS_JrwfQ';
var scopes = 'https://www.googleapis.com/auth/userinfo.email'; // 'https://www.googleapis.com/auth/plus.me';
var MY_API_ROOT = 'https://modirsham.appspot.com/_ah/api';
var MY_API_VER = 'v1';
var MY_API_NAME = 'api';

//REMOVED and moved as a direction line in site.html
//$.getScript('https://apis.google.com/js/client.js', function() {        
//	  $('body').append('<p>GOOGLE API  is loaded</p>');
//});


window.onload = function() {
    //gapi.client.setApiKey(apiKey);
    gapi.client.load(MY_API_NAME, MY_API_VER, null, MY_API_ROOT);
}


function decodeStr(coded) {
  coded = decodeURIComponent(coded);  
  var uncoded = "";
  var chr;
  for (var i = coded.length - 1; i >= 0; i--) {
    chr = coded.charAt(i);
    uncoded += (chr >= "a" && chr <= "z" || chr >= "A" && chr <= "Z") ?
      String.fromCharCode(65 + key.indexOf(chr) % 26) :
      chr; 
    }
  return uncoded;   
  } 

function getQueryStringParams(sParam) {
	var retval="";
    var sPageURL = window.location.search.substring(1);
    var sURLVariables = sPageURL.split('&');
    for (var i = 0; i < sURLVariables.length; i++) {
        var sParameterName = sURLVariables[i].split('=');
        if (sParameterName[0] == sParam) {
        	retval= sParameterName[1];
        }
    }
    return retval;
  }

//*************************************************************************************************************
function returnToday(){
	  var today = new Date();
      var dd = today.getDate();
      var mm = today.getMonth()+1;
      var yyyy = today.getFullYear();
      
      if(dd<10){dd='0'+dd;} 
      if(mm<10){mm='0'+mm;}
      
      var returnToday = yyyy + '' + mm +'' + dd ;
      delete yyyy;
      delete mm;
      delete dd;
      return returnToday;
}

function renothing(value){
	if (typeof(value) == "undefined")
	{
		return ""
	}
	else{
		return value
	}
}

function showmsg(msg) {
	$("#messagebar").html(msg);
	$("#dialog").dialog({
		modal: true,
		position: { my: 'top', at: 'top+350' },
		buttons: {
		Ok: function() {
			$( this ).dialog( "close" );
			}
		}
	});
}

function clearall(){
	
	$('input[type=text]').val (function () {
	    return '';
	})
}
